package com.sy.controller;

/**
 * 管理员controller
 * @Author:cxl
 * @Date: 2021/10/11 14:54
 */

import com.sy.entity.Admin;
import com.sy.service.AdminService;
import com.sy.util.CookieOperations;
import com.sy.vo.AdminVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;




@RestController
public class AdminController {

    @Autowired
    private CookieOperations cookieOperations;

    @Autowired
    private AdminService adminService;


    /**
     * @Author:cxl
     * 判断管理员名是否存在
     * @param adminName 管理员姓名
     * @return
     */
    @RequestMapping(value = "admin", method = RequestMethod.GET, params = {"adminName"})
    public boolean isAdminNameExists(@RequestParam("adminName") String adminName) {
       return adminService.isAdminNameExists(adminName);
    }

    /**
     * @Author:cxl
     * 判断管理员手机是否存在
     * @param adminPhone 管理员手机
     * @return
     */
    @RequestMapping(value = "admin", method = RequestMethod.GET, params = {"adminPhone"})
    public boolean isAdminPhoneExists(@RequestParam("adminPhone") String adminPhone) {
        return adminService.isAdminPhoneExists(adminPhone);
    }

    /**
     * @Author:cxl
     * 判断管理员手机是否存在
     * @param adminEmail 管理员邮箱
     * @return
     */
    @RequestMapping(value = "admin", method = RequestMethod.GET, params = {"adminEmail"})
    public boolean isAdminEmailExists(@RequestParam("adminEmail") String adminEmail) {
        return adminService.isAdminEmailExists(adminEmail);
    }

    /**
     * @Author:cxl
     * 注册操作
     * @param adminVo 管理员注册
     * @return
     */
    @RequestMapping(value = "regist", method = RequestMethod.POST)
    public boolean regist (@RequestBody AdminVo adminVo) {
        return adminService.addAdmin(adminVo);
    }



}
